// ---------------------------------------------------------------------
//
// -- 大厅结算界面
// -- author £
//
// ---------------------------------------------------------------------

cc.Class({
    extends: cc.Component,

    properties: {
        btnRank: cc.Node,
        btnChallenge: cc.Node,
        btnRestart: cc.Node,
        sharedView: cc.Sprite,
    },

    ctor: function () {
        this._update = false;
        this._updateCount = 0;
        this.tex = new cc.Texture2D();
        this._uItr = 0;
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        let UIManager = require('UIManager');

        this.sharedView.node.y = - UIManager.getRootY();
        this.sharedView.node.height = UIManager.getRealH();
        this.node.active = false;
    },

    start () {

    },

    show: function () {
        this.node.active = true;
        this._update = true;
        this._updateCount = 0;
    },

    hide: function () {
        this.node.active = false;
        this._update = false;
        this.sharedView.spriteFrame = null;
    },

    stop: function () {
        this._update = false;
    },

    update (dt) {
        if (!this._update) return;
            
        if (++ this._updateCount === 60)
            this._update = false;

        if (this._uItr !== 3) {
            ++this._uItr;
        } 

        this._uItr = 0;
        require('Platform').updateSub(this.tex, this.sharedView);
    },
});
